package com.example.lewisgao.blankactivity;

import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.os.Bundle;
import android.widget.RadioGroup;

/**
 * Created by LewisGao on 2015-06-29 0029.
 */
public class FragmentActivity extends Activity implements RadioGroup.OnCheckedChangeListener {

    RadioGroup radioGroup;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_main1);
        radioGroup = (RadioGroup) findViewById(R.id.radioGroup1);
        radioGroup.setOnCheckedChangeListener(this);

    }

    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        switch (checkedId) {
            case R.id.btn1: {
                Intent intent = new Intent(this, FragmentActivity2.class);
                startActivity(intent);
                break;
            }
            case R.id.btn2: {
                MyFragment2 myFragment2 = new MyFragment2();
                FragmentManager fragmentManager = getFragmentManager();
                FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
                fragmentTransaction.add(R.id.frame, myFragment2);
                fragmentTransaction.addToBackStack(null);
                fragmentTransaction.commit();
                break;
            }
            case R.id.btn3: {
                break;
            }
            case R.id.btn4: {
                break;
            }
        }
    }
}
